home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.mactech.com 2010
/
ftp.mactech.com.tar
/
ftp.mactech.com
/
machack
/
Hacks97
/
WarriorsProgress.sit
/
Warrior’s Progress
/
source code
/
Source
/
Libraries
/
Errors
/
OSError.cp
< prev
next >
Wrap
Text File
|
1997-06-28
|
2KB
|
135 lines
// OSError.cp
#ifndef OSError_h
#include "OSError.h"
#endif
#ifndef Assert_h
#include "Assert.h"
#endif
#ifndef DebugMessage_h
#include "DebugMessage.h"
#endif
#include "ConfigureOSErrorDebugging.h"
OSError::OSError( OSError& e )
: error( e.error )
{
e.Fix();
}
OSError::~OSError()
{
if ( displayDestroyedErrors && !OK() )
AnnounceDestruction( error );
}
void OSError::operator=( OSErr e )
{
if ( OK() )
error = e;
else
{
if ( displayCancelledErrors && e != noErr )
AnnounceCancellation( e, error );
if ( displayDuplicateErrors && e == noErr )
AnnounceDuplication( e );
}
}
void OSError::operator=( OSError& e )
{
if ( this == &e )
return;
*this = e.error;
e.Fix();
}
void OSError::Fix( OSErr e )
{
Assert( e != noErr );
if ( error == e )
error = noErr;
}
void OSError::Throw() const
{
if ( !OK() )
{
if ( displayThrownErrors )
AnnounceThrow( error );
throw *this;
}
}
void OSError::Throw( OSErr e ) const
{
Assert( e != noErr );
if ( error == e )
{
if ( displayThrownErrors )
AnnounceThrow( error );
throw *this;
}
}
void OSError::Debug() const
{
if ( displayExplicitErrors && !OK() )
AnnounceError( error );
}
void OSError::AnnounceCancellation( OSErr lost, OSErr kept )
{
DebugMessage message;
message += "\pError ";
message += lost;
message += "\p lost in favor of ";
message += kept;
message += "\p. ;error #";
message += lost;
message += "\p;error #";
message += kept;
message.Show();
}
void OSError::AnnounceDuplication( OSErr error )
{
DebugMessage message;
message += "\pError ";
message += error;
message += "\p duplicated. ;error #";
message += error;
message.Show();
}
void OSError::AnnounceDestruction( OSErr error )
{
DebugMessage message;
message += "\pError ";
message += error;
message += "\p destroyed. ;error #";
message += error;
message.Show();
}
void OSError::AnnounceThrow( OSErr error )
{
DebugMessage message;
message += "\pError ";
message += error;
message += "\p thrown. ;error #";
message += error;
message.Show();
}
void OSError::AnnounceError( OSErr error )
{
DebugMessage message;
message += "\p;error #";
message += error;
message.Show();
}